home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / Lookup 1.0d2 / Sources / CAddEntryAction.cp next >
Encoding:
Text File  |  1995-09-12  |  1.4 KB  |  51 lines  |  [TEXT/CWIE]

  1. /*
  2.     CAddEntryAction.cp
  3.  
  4.     Copyright © 1995 Alastair Rankine.
  5.     All Rights Reserved.
  6. */
  7.  
  8. #include "CAddEntryAction.h"
  9. #include "CLookupDocument.h"
  10. #include "CEntry.h"
  11. #include "ResourceIDs.h"
  12. #include "CEntryList.h"
  13.  
  14. #include <UAEGizmos.h>
  15.  
  16. // -------------------------------------------------------------
  17. // CLASS CAddEntryAction
  18.  
  19. CAddEntryAction::CAddEntryAction(CLookupDocument & inLookupDocument, const CEntry & inEntry)
  20.     : LAEAction(STRx_RedoEdit, str_RedoAdd)
  21. {
  22.     LAEStream redo(kAECoreSuite, kAECreateElement);
  23.     
  24.     //    keyAEInsertHere - Create the record at the beginning of the document
  25.     redo.WriteKey(keyAEInsertHere);
  26.     redo.OpenRecord(typeInsertionLoc);
  27.         redo.WriteKey(keyAEObject);
  28.         redo.WriteSpecifier(&inLookupDocument);
  29.         redo.WriteKey(keyAEPosition);
  30.         redo.WriteEnumDesc(kAEBeginning);
  31.     redo.CloseRecord();
  32.  
  33.     //    keyAEObjectClass - Create a CEntry
  34.     redo.WriteKey(keyAEObjectClass);
  35.     redo.WriteTypeDesc(CEntry::kModelID);
  36.  
  37.     //    keyAEPropData - Copy the properties from inEntry
  38.     StAEDescriptor objProps;
  39.     inEntry.GetDifferentAEProperties(sEmptyEntry, objProps.mDesc);
  40.     redo.WriteKeyDesc(keyAEPropData, objProps.mDesc);
  41.  
  42.     // Close the redo, and assign the AE to the Redo event.
  43.     StAEDescriptor createEvent;
  44.     redo.Close(&createEvent.mDesc);
  45.     SetRedoAE(createEvent.mDesc);
  46.  
  47.     // The undo AE is a lot simpler. Basically a delete event with the result from
  48.     // the create as the direct parameter.
  49.     SetUndoAE(kAECoreSuite, kAEDelete, true);
  50. }
  51.